package com.yz.newspaper.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class CorsConfig implements WebMvcConfigurer {  //WebMvcConfigurer 定义拦截器，针对跨域问题
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        log.info("跨域拦截器23");
        registry.addMapping("/**")  //所有接口
                .allowedOriginPatterns("*")   //支持那些域跨域
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")  //支持方式
                .allowCredentials(true)  //是否允许发送Cookie
                .maxAge(3600)
                .allowedHeaders("*");

    }
}
